package com.zzyl.controller.manager;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing/level")
@Api(tags = "护理等级管理")
public class NursingLevelController {

    @Autowired
    private NursingLevelService nursingLevelService;

    @GetMapping(path = "/search")
    @ApiOperation("分页查询护理等级列表")
    public ResponseResult<PageResponse<NursingLevelVo>> findNursingLevelPage(String Name, Integer status, Integer pageNum, Integer pageSize) {
        return ResponseResult.success(nursingLevelService.findNursingLevelPage(Name, status, pageNum, pageSize));
    }

    @PostMapping
    @ApiOperation("新增护理等级")
    public ResponseResult<Void> addNursingLevel(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.addNursingLevel(nursingLevelDto);
        return ResponseResult.success();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理等级")
    public ResponseResult<NursingLevelVo> findNursingLevelById(@PathVariable Long id) {
        return ResponseResult.success(nursingLevelService.findNursingLevelById(id));
    }

    @PutMapping
    @ApiOperation("修改护理等级")
    public ResponseResult<Void> updateNursingLevel(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.updateNursingLevel(nursingLevelDto);
        return ResponseResult.success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除护理等级")
    public ResponseResult<Void> deleteNursingLevel(@PathVariable Long id) {
        nursingLevelService.deleteNursingLevel(id);
        return ResponseResult.success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用/禁用护理等级")
    public ResponseResult<Void> updateNursingLevelByStatus(@PathVariable Long id, @PathVariable Integer status) {
        nursingLevelService.updateNursingLevelByStatus(id, status);
        return ResponseResult.success();
    }

    @GetMapping
    @ApiOperation("查询所有护理等级")
    public ResponseResult<List<NursingLevelVo>> findAllNursingLevel() {
        return ResponseResult.success(nursingLevelService.findAllNursingLevel());
    }
}
